/*
 * @Date: 2024-11-18 15:04:11
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-11-18 15:04:11
 * @Description: 单位管理相关接口
 */

import { defAxios as request, blobAxios } from '@/utils/http'

export function useUnitApi() {
    return {
        savePubagency,
        disableOrEnablePubagency,
        deletePubAgency,
        getPubAgencyByGuid,
        refreshSysAdCache,
        exportPubagencyInfo,
        downloadTemplate,
        importExcelForpubAgencyInfo

    }
}

// 保存单位信息
function savePubagency(params) {
    return request({
        url: '/pubAgency/savePubAgency',
        method: 'post',
        data: params
    })
}
// 停用启用
function disableOrEnablePubagency(params) {
    return request({
        url: '/pubAgency/disableOrEnablePubAgency',
        method: 'post',
        data: params
    })
}
// 删除单位信息
function deletePubAgency(params) {
    return request({
        url: '/pubAgency/deletePubAgency',
        method: 'post',
        data: params
    })
}
// 根据单位guid获取单位信息
function getPubAgencyByGuid(params) {
    return request({
        url: '/pubAgency/getPubAgencyByGuid',
        method: 'post',
        data: params
    })
}
//区划刷新缓存
function refreshSysAdCache(params) {
    return request({
        url: '/pubAgency/refreshSysAdCache',
        method: 'post',
        data: params
    })
}

/**
 * 单位导出
 * 
 * @param {String} params
 */
async function exportPubagencyInfo(params) {
    return blobAxios({
        url: '/pubAgency/exportPubagencyInfo',
        method: 'post',
        data: params,
        responseType: "blob",
    })
}
/**
 * 单位下载
 * 
 * @param {String} params
 */
async function downloadTemplate(params) {
    return request({
        url: '/pubAgency/downloadTemplate',
        method: 'post',
        params: params,
        responseType: "blob",
    })
}
/**
 * 单位导入
 * 
 * @param {String} params
 */
async function importExcelForpubAgencyInfo(params) {
    return request({
        url: '/pubAgency/importExcelForpubAgencyInfo',
        method: 'post',
        data: params,
    })
}